#include <sys/types.h>
       #include <sys/stat.h>
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
           struct stat sb;

           if (argc != 2) {
               fprintf(stderr, "Usage: %s <pathname>\n", argv[0]);
               exit(EXIT_FAILURE);
           }

           if (stat(argv[1], &sb) == -1) {
               perror("stat");
               exit(EXIT_FAILURE);
           }

           
           printf("文件: ‘%s’\n", argv[1]);
           printf("大小:%lld      ",
                   (long long) sb.st_size);
           printf("块:%lld      ",
                   (long long) sb.st_blocks);
           printf("IO块: %ld     ",
                   (long) sb.st_blksize);
           switch (sb.st_mode & S_IFMT) {
           case S_IFBLK:  printf("块设备文件\n");            break;
           case S_IFCHR:  printf("字符设备文件\n");        break;
           case S_IFDIR:  printf("目录\n");               break;
           case S_IFIFO:  printf("管道文件\n");               break;
           case S_IFLNK:  printf("符号链接文件\n");                 break;
           case S_IFREG:  printf("普通文件\n");            break;
           case S_IFSOCK: printf("套接字文件\n");                  break;
           default:       printf("未知?\n");                break;
           }
           printf("设备:%ldd       ",
                   (long) sb.st_dev);
	   printf("Inode:%ld       ", 
	           (long) sb.st_ino);

           printf("硬连接:%ld\n", (long) sb.st_nlink);
           printf("权限:                UID：（%ld）   GID：（%ld）\n",
                   (long) sb.st_uid, (long) sb.st_gid);
           
           printf("最近访问:         %s", ctime(&sb.st_atime));
           printf("最近更改:         %s", ctime(&sb.st_ctime));
           printf("最近改动:         %s", ctime(&sb.st_mtime));

           exit(EXIT_SUCCESS);
       }

